﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using MVCManage.Model;
using MVCManage.BLL;
using System.Web.Http.Results;
namespace MVCManage.Api.Controllers
{
    public class SpecController : ApiController
    {
        GoodsSpecBLL bll = new GoodsSpecBLL();
        // GET: api/Spec
      

        // GET: api/Spec/5
        public ResultData<List<SpecDto>> Get()
        {
            var list = from n in bll.Query()
                       select new SpecDto()
                       {
                           GSKID = n.gskId,
                           Name = n.name,
                           Values = from g in n.GoodsSpecValue
                                    select new SpecValueDto()
                                    {
                                        Code = g.code,
                                        GSVID = g.gsvId,
                                        Value = g.value
                                    }
                       };
            ResultData<List<SpecDto>> result = new ResultData<List<SpecDto>>();
            result.code = 1;
            result.msg = "ok";
            result.data = list.ToList();

            return result;
        }

        // POST: api/Spec
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/Spec/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/Spec/5
        public void Delete(int id)
        {
        }
    }
}
